package com.zhangzhan.service.impl;

import com.zhangzhan.domain.entity.LoginUser;
import com.zhangzhan.utils.SecurityUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 张一恒
 * @version 1.0
 * @description:
 * @date 2022/12/7 8:57
 */
@Service("ps")
public class PermissionsService {

    //权限控制
    public boolean hasPermissions(String hasPermis) {
        //判断当前用户是否为超级管理员
        if (SecurityUtils.isAdmin()) {
            return true;
        }
        //如果是其他用户则判断当前用户接口权限
        LoginUser loginUser = SecurityUtils.getLoginUser();
        List<String> permissions = loginUser.getPermissions();
        return permissions.contains(hasPermis);
    }
}
